package edu.scau.mis.web.controller;

import edu.scau.mis.cloth.entity.GsClothes;
import edu.scau.mis.cloth.entity.GsOrder;
import edu.scau.mis.cloth.service.GsOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("gsOrder")
public class GsOrderController {
    @Autowired
    private GsOrderService gsOrderService;
//    查看全部订单的信息
    @GetMapping("/list")
    public List<Map<String,Object>> queryAll(){
        return this.gsOrderService.queryAll();
    }

    @GetMapping("{id}")
    public Map<String,Object> queryOrderById(@PathVariable("id") String id){
        return this.gsOrderService.queryOrderById(id);
    }

    @GetMapping("/createOrder")
    public String createOrder() {
//        使用时间戳生成一个流水号，先创建一个初始订单，此后添加的订单项加入到该订单中
        String id = new Date().getTime() + "";
        this.gsOrderService.insert(id);
        return id;
    }


}

